package rickyGame.game.action.state
{
	import ricky.animate.AnimSprite;
	import ricky.game.graphic.Graphic;
	
	import rickyGame.game.Fighter;
	import rickyGame.game.action.ActionHelper;
	
	/**
	 * 安装特效魔法状态行动
	 */
	public class InstallSkillStateAct extends  StateAct
	{
		/**
		 * actor:Pu 目标</br>
		 *  model:String 模型</br>
		 * endtime:Number 结束时间（毫秒）</br>
		 * index:int  索引位置</br>
s		 */
		public function InstallSkillStateAct(actor:Fighter, model:String,endtime:Number,index:int=-1)
		{
			super(actor, null, endtime);
			this._model=model;
			_index=index;
		}
		
		override public function begin():void
		{
			_buf=new AnimSprite();
			_buf.loadModel(_model);
			if(_index>=0)
			{
				if(_index>Graphic(actor.graphic).numChildren)
					_index=Graphic(actor.graphic).numChildren;
				Graphic(actor.graphic).addChildAt(_buf,_index);
			}
			else
				Graphic(actor.graphic).addChild(_buf);
			super.begin();
		}
		
		override public function end():void
		{
			if(_buf.parent)
				_buf.parent.removeChild(_buf);
		}
		
		private var _model:String;
		private var _buf:AnimSprite;
		private var _index:int//位置
	}
}